#pragma once

#include <iostream>
#include <string>
#include <unistd.h>
#include <cstdint>
#include <memory>
#include "Connection.hpp"
#include "log.hpp"
#include "TcpServer.hpp"
using namespace std;

#define SIZE 1024

class Connection;
extern Log lg;
class Task
{
public:
    Task(shared_ptr<Connection> tmp,bool op)//传过来要处理 对象
    :con_(tmp)
    ,op_(op)
    {}

    ~Task()
    {}
    
    void Run(bool op)
    {
        con_.expired();
        auto connection=con_.lock();
        if(op==true)
        {
            connection->recv_cb_(connection);
        }
        else 
        {
            connection->send_cb_(connection);
        }
    }

    void operator()()
    {
        Run(op_);
    }

private:
    weak_ptr<Connection> con_;
    bool op_;

    int oper_;
    int result_;
    int exitcode_;
};